Skip to content

Conversation

@sarahxsanders
Copy link
Contributor

getting this PR in draft so peeps can start reviewing!!!!!

adds a Django example project demoing Python SDK integration

Testing

  • ran PostHog wizard against the Django example project
  • wizard successfully detected Django and completed integration
  • ran wizard-workbench evaluator against the resulting changes

evaluator scored 4/5:

  • app sanity check 5/5
  • posthog implementation 4/5
  • posthog insights/events 5/5

eval correctly recognized latest python SDK patterns, but there were a few things I still need to tweak:

  • No reverse proxy configuration: The Django example lacks a reverse proxy setup to circumvent ad blockers when sending events to PostHog. This is documented as a best practice but not implemented. [MEDIUM]
  • Missing python-dotenv in install instructions: README says pip install posthog but requirements.txt includes python-dotenv which is needed for .env loading. Should be pip install -r requirements.txt. [LOW]

looking into these two

see output:

## PR Evaluation Report

### Summary
This PR adds a complete Django example project demonstrating PostHog integration with server-side Python SDK, ...

Agent completed evaluation

--- Usage ---
Total cost: $0.9457
Input tokens: 16
Output tokens: 4503

Confidence score: 4/5

--- TEST RUN: Review Comment Preview ---
Now I have all the information needed to evaluate this PR. Let me compile the evaluation report.

---

## PR Evaluation Report

### Summary
This PR adds a complete Django example project demonstrating PostHog integration with server-side Python SDK, along with CI workflow infrastructure changes (wizard-ci trigger workflow, disabled old test workflows) and updates to LLM prompts for Django-specific guidance.

| Files changed | Lines added | Lines removed |
|---------------|-------------|---------------|
| 31 | +1560 | -17 |

### Confidence score: 4/5 👍

- **No reverse proxy configuration**: The Django example lacks a reverse proxy setup to circumvent ad blockers when sending events to PostHog. This is documented as a best practice but not implemented. [MEDIUM]
- **Missing `python-dotenv` in install instructions**: README says `pip install posthog` but `requirements.txt` includes `python-dotenv` which is needed for `.env` loading. Should be `pip install -r requirements.txt`. [LOW]

---

### File changes

| Filename | Score | Description |
|----------|-------|-------------|
| `basics/django/requirements.txt` | 5/5 | Correctly specifies Django 4.2+, `posthog` SDK, and `python-dotenv` dependencies |
| `basics/django/posthog_example/settings.py` | 5/5 | Proper PostHog configuration via env vars, middleware correctly placed after AuthenticationMiddleware |
| `basics/django/core/apps.py` | 5/5 | PostHog initialized in `AppConfig.ready()` following Django best practices |
| `basics/django/core/views.py` | 5/5 | Comprehensive PostHog integration with context-based API, identify, capture, feature flags, error tracking, and group analytics |
| `basics/django/core/urls.py` | 5/5 | Clean URL routing for all PostHog example views |
| `basics/django/core/templates/core/*.html` | 4/5 | Functional Django templates with CSRF handling; inline styles could be extracted |
| `basics/django/README.md` | 4/5 | Comprehensive documentation but install instructions incomplete |
| `basics/django/manage.py` | 5/5 | Standard Django management script |
| `basics/django/.env.example` | 5/5 | Documents required environment variables |
| `basics/django/.gitignore` | 5/5 | Appropriate Python/Django ignores |
| `.github/workflows/wizard-ci-trigger.yml` | 5/5 | Well-structured CI workflow for triggering wizard tests on PRs |
| `.github/workflows/e2e.yml` | 4/5 | Disabled via `if: false` - intentional but should be documented |
| `.github/workflows/integration.yml` | 4/5 | Disabled via `if: false` - intentional but should be documented |
| `.gitignore` | 5/5 | Added Python patterns (venv, __pycache__, db.sqlite3) |
| `llm-prompts/basic-integration/1.0-begin.md` | 5/5 | Updated to detect Python projects and PostHog SDK patterns |
| `llm-prompts/basic-integration/1.1-edit.md` | 5/5 | Added Django-specific middleware and context API guidance |
| `llm-prompts/basic-integration/1.2-revise.md` | 5/5 | Added Django system checks and Python formatting |
| `scripts/build-examples-mcp-resources.js` | 5/5 | Added Django docs URL and example configuration |
| `package.json` | 5/5 | Version bump and added `build` script alias |

---

### App sanity check: 5/5 ✅

| Criteria | Result | Description |
|----------|--------|-------------|
| **App builds and runs** | Yes | Django system checks pass with no issues |
| **Preserves existing env vars & configs** | Yes | All existing configurations maintained; new Django app is additive |
| **No syntax or type errors** | Yes | All Python files are syntactically correct |
| **Correct imports/exports** | Yes | All imports resolve correctly (posthog, django modules) |
| **Minimal, focused changes** | Yes | Changes are focused on adding Django example and supporting infrastructure |

#### Issues
None - the app is well-structured and follows Django conventions.

<details>
<summary><h4>Other completed criteria</h4></summary>

- Environment variables documented in `.env.example`
- Build configuration valid (MCP resources build completes successfully)
- Consistent with existing project patterns
- Clear, readable code with docstrings
- Appropriate error handling in views
</details>

---

### PostHog implementation: 4/5 ✅

| Criteria | Result | Description |
|----------|--------|-------------|
| **PostHog SDKs installed** | Yes | `posthog` package in `requirements.txt` |
| **PostHog client initialized** | Yes | Initialized in `CoreConfig.ready()` with API key and host from Django settings |
| **capture()** | Yes | Used throughout views with context-based API (`new_context()`, `capture()`) |
| **Identify()** | Yes | `identify_context()` called on login with user properties via `tag()` |
| **Error tracking** | Yes | `posthog.capture_exception(e)` implemented in `trigger_error_view` |
| **Reverse proxy** | No | Not implemented - events sent directly to PostHog |

#### Issues
- **No reverse proxy**: Server-side tracking doesn't have ad blocker issues, but for frontend-backend correlation mentioned in README's "Frontend integration" section, a reverse proxy would be beneficial. [MEDIUM]

<details>
<summary><h4>Other completed criteria</h4></summary>

- PostHog middleware `PosthogContextMiddleware` correctly placed after `AuthenticationMiddleware`
- API key via environment variable, not hardcoded
- Feature flags implemented with `feature_enabled()` and `get_feature_flag_payload()`
- Group analytics implemented with `group_identify()` and group parameter in capture
- Context-based API correctly used with `new_context()` blocks
- PII stored in `tag()` calls, not in event properties
- Debug mode enabled in development
- Disabled flag support for testing
</details>

---

### PostHog insights and events: 5/5 ✅

| Filename | PostHog events | Description |
|----------|-----------------|-------------|
| `core/views.py` | `user_logged_in` | Captures login method and identifies user with email, username, name, staff status, date_joined |
| `core/views.py` | `user_logged_out` | Tracks session end for user lifecycle analysis |
| `core/views.py` | `dashboard_viewed` | Page engagement tracking with staff status property |
| `core/views.py` | `profile_viewed` | Page engagement tracking |
| `core/views.py` | `burrito_considered` | Custom conversion event with total_considerations property for funnel analysis |
| `core/views.py` | `error_triggered` | Error tracking demo with error_type and error_message properties |
| `core/views.py` | `feature_used` | Group analytics event with company group and feature_name property |
| `core/views.py` | `capture_exception()` | Exception tracking for ValueError, KeyError, and generic exceptions |

#### Issues
None - events are well-designed for product analytics.

<details>
<summary><h4>Other completed criteria</h4></summary>

- Events represent real user actions (login, logout, page views, conversions)
- Events enriched with relevant properties (login_method, is_staff, total_considerations)
- Feature flag evaluation tracked with person_properties
- Group analytics enabled for company-level insights
- Error tracking captures exception details
- Events can build funnels (login → dashboard → burrito consideration)
- Event naming consistent (snake_case)
</details>

---

Reviewed by wizard workbench PR evaluator
--- END PREVIEW ---


=== Evaluation Complete ===

@sarahxsanders sarahxsanders marked this pull request as ready for review January 15, 2026 22:21
@sarahxsanders sarahxsanders requested a review from a team January 15, 2026 22:21
@daniloc
Copy link
Collaborator

daniloc commented Jan 15, 2026

this is awesome! there's going to be a little conforming to the new skill generation structure to do on this one, using commandments.yaml and setting up skills.yaml. we can talk through that tomorrow if there's anything head-scratcher on it, and get this merged.

@sarahxsanders sarahxsanders changed the title add Django skill feat: add Django skill Jan 16, 2026
@sarahxsanders
Copy link
Contributor Author

sarahxsanders commented Jan 16, 2026

closing this... none of my commits are updating??

new: #89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants